﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Heritage.Codebox
{
    public class Logger
    {
        public const string DEBUG = "DEBUG";
        public const string VERBOSE = "VERBOSE";
        public const string INFO = "INFO";
        public const string WARN = "WARN";
        public const string ERROR = "ERROR";
        public const string FATAL = "FATAL";

        public static void Log(string level, string message) 
        {
            HeritageEntities ents = new HeritageEntities();
            LogTable entry = LogTable.CreateLogTable(1, DateTime.Now, level, message);
            entry.Principal = Utils.GetCurrentUser() != null? Utils.GetCurrentUser().Username: "";             
            ents.LogTable.AddObject(entry);
            ents.SaveChanges();
        }
    }
}